# from qiniu import Auth, put_file, etag
# from flask import current_app
# import qiniu.config
# import configparser
# import sys

# """
# 读取配置文件
# """
# try:
#     cf = configparser.ConfigParser()
#     # cf.optionsxform = str  # 若出现不分大小写字符的情况 用这个
#     cf.read('./conf/config.ini')
#     qiniukey = cf.get('common','qiniukey')
#     qiniusecret = cf.get('common','qiniusecret')
#     qiniuurl = cf.get('common','qiniuurl')
# except Exception as e:
#     current_app.logger.debug('请确保config.ini是否存在,或配置不正确！')
#     current_app.logger.debug(e)
#     sys.exit(0)

# class qiniuUtils(object):

#     def __init__(self):
#         access_key = qiniukey
#         secret_key = qiniusecret
#         # 构建鉴权对象
#         self.auth = Auth(access_key, secret_key)
#         self.bucket_name = "myvideo13"
    
#     def upload(self,filepath,filename,path):
#         #上传后保存的文件名
#         key = path + filename
#         #生成上传 Token，可以指定过期时间等
#         token = self.auth.upload_token(self.bucket_name, key, 3600)
#         #要上传文件的本地路径
#         localfile = filepath
#         ret, info = put_file(token, key, localfile, version='v2') 
#         if info.status_code == 200:
#             # 上传图片成功
#             # 拼接完整url地址
#             full_url = qiniuurl+ ret["key"]
#             return full_url
#         else:
#             # 封装好的工具类异常需要抛出，不能私自解决异常 否则外界调用遇到异常没法解决
#             raise Exception(info.exception)